﻿using RockBus.DataContracts;
using RockBus.Messages.Interfaces;

namespace RockBus.Subscription.Interfaces
{
    public interface IEvaluator<in TEvaluatorConfiguration>
    {
        /// <summary>
        /// Will be called by the EvaluationManager to initialize the Evaluators. The implementation is required to reinitialize the state of the Evaluator.
        ///  This implementation is not required to be thread-safe, because the EvaluationManager will handle the synchronization accross calls to Initialize and Evaluate.
        /// </summary>
        /// <param name="subscriptionFilterConfiguration"></param>
        void Initialize(TEvaluatorConfiguration configuration);

        /// <summary>
        /// Will be called for every message. There can be multiple SubscriptionEvaluator configured to run sequentially.
        ///  This method will add or remove evaluation results from the SubscriptionEvaluationResult.
        /// </summary>
        /// <param name="subscriptionEvaluationResult">Running tab of subscription evaluation results.</param>
        void Evaluate(IMessage messageWrapper, EvaluationResult evaluationResult);
    }
}